<!--
 * @Author: ltl
 * @Date: 2023-8-17 11:07:23
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-11-08 14:47:21
 * @Description: 个人中心页面头部-优学高手
-->
<template>
  <div class="head">
    <div class="nav">我的</div>
    <div class="head-content">
      <div class="user-info">
        <div class="use-info-item">
          <img alt="" :src="`/gw/ucsapi/head_photo/user/${userInfo.studentNumber}/${size}`" class="avatar-img" @click="goInfo"/>
          <div class="student-info">
            <p class="name">{{getDecode(userInfo.realName)}}</p>
            <p class="class-name" v-if="userInfo.gradeName">{{ userInfo.gradeName }}</p>
          </div>
        </div>
        <div class="sign-in" @click="gradeChange">
          <img src="../../assets/images/user/switchClass.png" alt="">
          <span>切换年级</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import aes from '@/utils/aes';
import { externalLinkServices } from '@/api';
export default {
  data () {
    return {
      size: 100,
      newGradeCode: ''
    };
  },
  props: {
    userInfo: {
        type: Object
    }

  },
  created () {
    this.newGradeCode = localStorage.getItem('gradeCode') ? localStorage.getItem('gradeCode') : '0001';
  },
  methods: {
    gradeChange () {
      this.$router.replace({ path: '/gradeChange', query: { type: 1, gradeCode: this.newGradeCode } });
    },
    goInfo () {
      window.location.href = externalLinkServices.userInfolLink;
    },
    getDecode (name) {
      if (name) {
        return aes.decode(name) || '';
      } else {
        return '';
      }
    },
    changeSignStatus () {
      this.$emit('changeSignStatus');
    }
  }
};
</script>
<style lang="scss" scoped>
.nav {
  width: 100%;
  position: absolute;
  left: 0;
  top: 15px;
  text-align: center;
  font-size: 18px;
  font-family: PingFangSC-Medium, sans-serif;
  color: #ffffff;
}
.head {
  position: relative;
  .head-content {
    position: absolute;
    width: 100%;
    // left: 0;
    // bottom: 0;
    .user-info {
      width: 350px;
      box-sizing: border-box;
      min-height: 98px;
      margin: 0 auto;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 12px;
    }
    .use-info-item {
      display: flex;
      align-items: center;
    }
    .avatar-img {
      width: 68px;
      height: 68px;
      border-radius: 50%;
    }
    .student-info {
      font-family: PingFang SC, PingFang SC-Regular, sans-serif;
      text-align: left;
      color: #333333FF;
      line-height: 26px;
      margin-left: 12px;
      .name {
        width: 160px;
        font-size: 18px;
        font-weight: 500;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .class-name{
        font-size: 12px;
        font-weight: 400;
      }
    }
    .sign-in {
      img{
        width: 18px;
        height: 18px;
        margin: 0 5px 1px 0;
      }
      span{
        font-size: 14px;
        vertical-align: middle;
      }
    }
  }
}
</style>
